- volume_options = [[t(:'change_volume_form.quiet_desc'), 'quiet'], [t(:'change_volume_form.normal_desc'), :normal], [t(:'change_volume_form.loud_desc'), :loud]]

%main.sistema
  %h1= t(:'change_volume_form.change_your_email_settings')

  - if @discussion_reader
    %h3= "#{t(:'common.thread')}: #{@discussion_reader.discussion.title}"
    %p= t(:'change_volume_form.when_would_you_like_to_be_emailed_discussion')
    = form_tag(email_actions_set_discussion_volume_path, method: :PUT) do
      %input{type: :hidden, name: 'unsubscribe_token', value: params[:unsubscribe_token]}
      %input{type: :hidden, name: 'discussion_id', value: @discussion_reader.discussion_id}
      - if @stance
        %input{type: :hidden, name: 'poll_id', value: @stance.poll_id}
      %select{name: :value}
        = options_for_select(volume_options, selected: @discussion_reader.volume)
      %input{type: 'submit', value: t(:'common.action.save')}

  - if @stance
    %h3= "#{t(:"poll_types.#{@stance.poll.poll_type}")}: #{@stance.poll.title}"
    %p= t(:'change_volume_form.when_would_you_like_to_be_emailed_poll_type', poll_type: I18n.t(:"poll_types.#{@stance.poll.poll_type}"))
    = form_tag(email_actions_set_poll_volume_path, method: :PUT) do
      %input{type: :hidden, name: 'unsubscribe_token', value: params[:unsubscribe_token]}
      %input{type: :hidden, name: 'poll_id', value: @stance.poll.id}
      - if @discussion_reader
        %input{type: :hidden, name: 'discussion_id', value: @discussion_reader.discussion_id}
      %select{name: :value}
        = options_for_select(volume_options, selected: @stance.volume)
      %input{type: 'submit', value: t(:'common.action.save')}

  - if @membership
    %h3= "#{t(:'common.group')}: #{@membership.group.full_name}"
    %p= t(:'change_volume_form.when_would_you_like_to_be_emailed_group')
    = form_tag(email_actions_set_group_volume_path, method: :PUT) do
      %input{type: :hidden, name: 'unsubscribe_token', value: params[:unsubscribe_token]}
      -if @discussion_reader
        %input{type: :hidden, name: 'discussion_id', value: @discussion_reader.discussion_id}
      -if @stance
        %input{type: :hidden, name: 'poll_id', value: @stance.poll_id}
      %select{name: :value}
        = options_for_select(volume_options, selected: @membership.volume)
      %input{type: 'submit', value: t(:'common.action.save')}
    %p
      %i=t(:'change_volume_form.changes_all_discussions_and_polls_in_group')

  %h3=t(:'change_volume_form.what_do_the_options_mean')
  %p
    %b= t(:'change_volume_form.quiet_desc')
    \-
    = t(:'change_volume_form.quiet_explained')
  %p
    %b= t(:'change_volume_form.normal_desc')
    \-
    = t(:'change_volume_form.normal_explained')
  %p= t(:'change_volume_form.normal_excludes_mentioning_html', url: "/email_preferences?unsubscribe_token=#{params[:unsubscribe_token]}")
  %p
    %b= t(:'change_volume_form.loud_desc')
    \-
    = t(:'change_volume_form.loud_explained')
